@extends('default.layouts.adminPublic')
@section('title', '签写合同')
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/vendor/jedate/skin/jedate.css')}}">
    <link rel="stylesheet" href="{{asset('/default/css/admin/indexList.css')}}">
    <style>
        .wicon{ background-image:url("");
            background-repeat:no-repeat; background-position:right center; cursor:pointer; }
    </style>
    @endsection
    @section('content')
            <!--导航开始-->
    <div class="crumb_warp">
        <i class="fa fa-home"></i> <a href="{{url('admin/com_user_reg')}}">首页</a> &raquo; 用户管理
    </div>
    <!--导航结束-->
    <!--结果集标题与导航组件 开始-->
    <div class="con">

        <div class="conMain">
            <div class="manage"><h1>签写合同</h1></div>
            <div class="conInfo">
                <div class="manage" style="padding: 0; margin-bottom: 10px;">
                    @if(count($errors)>0)
                        <div class="mark">
                            @if(is_object($errors))
                                @foreach($errors->all() as $error)
                                    <p>{{$error}}</p>
                                @endforeach
                            @else
                                <p>{{$errors}}</p>
                            @endif
                        </div>
                    @endif
                </div>
                <div class="conAddList">
                    <form action="{{url('admin/contract')}}" method="post" name="contractForm" id="contractForm"
                          onsubmit="return checkForm('#contractForm')">
                        <input type="hidden" name="uid" id="uid" value="{{$uid}}">
                        <input type="hidden" name="vip_days" id="vip_days" value="">
                        {{csrf_field()}}
                        <dl>
                            <dt><i class="require">*</i>服务类别：</dt>
                            <dd>
                                <select name="refill_type" id="refill_type" style="width:100px;">
                                    <option value="1">正常开通</option>
                                    <option value="2">提前继费</option>
                                </select>
                                <select name="category" id="category" style="width:160px;">
                                    <option value="">请选择套餐</option>
                                    @if(count($vip_package) > 0)
                                        @foreach($vip_package as $v )
                                            <option value="{{$v->id}}">{{$v->vipname}}</option>
                                        @endforeach
                                    @endif
                                </select>
                            </dd>
                        </dl>
                        <dl>
                            <dt><i class="require">*</i>服务时间：</dt>
                            <dd>
                                <input class="wicon" name="start_time" style="width:180px;" id="start_time"
                                       value="{{old('start_time')}}" type="text" readonly>
                                <span>~</span>
                                <input class="wicon" name="end_time" style="width:180px;" id="end_time"
                                       value="{{old('end_time')}}" type="text" readonly>
                            </dd>
                        </dl>

                        <dl>
                            <dt>会员内简历数：</dt>
                            <dd><input type="text" class="inpText" style="width:140px;"
                                       value="{{old('vip_resume_number')}}" name="vip_resume_number"
                                       id="vip_resume_number"></dd>
                        </dl>

                        <dl>
                            <dt>会员期内积分：</dt>
                            <dd><input type="text" class="inpText" style="width:140px;" value="{{old('vip_integral')}}"
                                       name="vip_integral" id="vip_integral"></dd>
                        </dl>
                        <dl>
                            <dt>会员内职位数：</dt>
                            <dd><input type="text" class="inpText" style="width:140px;" name="vip_post_number"
                                       value="{{old('vip_post_number')}}" id="vip_post_number"></dd>
                        </dl>
                        <dl>
                            <dt>非会员简历数：</dt>
                            <dd><input type="text" class="inpText" style="width:140px;" value="{{old('resume_number')}}"
                                       name="resume_number" id="resume_number"></dd>
                        </dl>
                        <dl>
                            <dt>非会员积分：</dt>
                            <dd><input type="text" class="inpText" style="width:140px;" value="{{old('integral')}}"
                                       name="integral" id="integral"></dd>
                        </dl>
                        <dl>
                            <dt>启停次数：</dt>
                            <dd><input type="text" class="inpText" style="width:140px;" value="{{old('stop_number')}}"
                                       name="stop_number" id="stop_number">
                            <span style="margin-left:20px; color:#ff4400">注：只填写纯数字，设置后可以开启启停功能</span>
                            </dd>
                        </dl>
                        <dl>
                            <dt><i class="require">*</i>销售代表：</dt>
                            <dd>
                                <select name="responsible_crm_uid" id="responsible_crm_uid" style="width:160px;">
                                    <option value="">请选择销售代表</option>
                                    @if(count($crmUser) > 0)
                                        @foreach($crmUser as $v )
                                            <option value="{{$v->uid}}">{{$v->worker_name}}</option>
                                        @endforeach
                                    @endif
                                    <option value="0">其他</option>
                                </select>
                            </dd>
                        </dl>
                        <dl>
                            <dt><i class="require">*</i>支付方式：</dt>
                            <dd>
                                <select name="pay" id="pay" style="width:160px;">
                                    <option value="">请选择收款方式</option>
                                    @if(count($pay) > 0)
                                        @foreach($pay as $v )
                                            <option value="{{$v->opt_id}}">{{$v->opt_name}}</option>
                                        @endforeach
                                    @endif
                                </select>
                            </dd>
                        </dl>
                        <dl>
                            <dt>收费金额：</dt>
                            <dd><input type="text" class="inpText" value="{{old('money')}}" name="money" id="money">
                            </dd>
                        </dl>
                        <dl>
                            <dt><i class="require">*</i>支付时间：</dt>
                            <dd>
                                <input class="wicon" name="pay_time" value="{{old('pay_time')}}" style="width:220px;"
                                       id="pay_time" type="text" readonly>
                            </dd>
                        </dl>
                        <dl style="height: 100px;">
                            <dt style="height: 100px;">备注：</dt>
                            <dd style="height: 100px;"><textarea name="remark" id="remark"
                                                                 style="height: 68px; width: 600px;">{{old('remark')}}</textarea>
                            </dd>
                        </dl>
                        <dl>
                            <dt></dt>
                            <dd>
                                <input type="submit" class="sub" value="签写合同">
                                <input type="button" class="sub but" onclick="history.go(-1)" value="返回">
                            </dd>
                        </dl>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->
@endsection

@section('footerjs')
    @parent
    <script type="text/javascript" src="{{asset('/vendor/jedate/jquery.jedate.min.js')}}"></script>
    <script>
        $(function(){
            var contractForm = $('#contractForm');
            contractForm.find('#category').val('{{old('category')}}');
            contractForm.find('#pay').val('{{old('pay')}}');
            contractForm.find('#refill_type').val('{{$type}}');
            contractForm.find('#category,#refill_type').bind("change", function(){
                $.post("/admin/change_vip", {'id': contractForm.find('#category').val(),'uid': contractForm.find('#uid').val(),'refill_type': contractForm.find('#refill_type').val(), '_token': "{{csrf_token()}}"}, function(data){
                    contractForm.find('#start_time').val(data.start_time);
                    contractForm.find('#end_time').val(data.end_time);
                    contractForm.find('#vip_resume_number').val(data.vip_resume_number);
                    contractForm.find('#vip_integral').val(data.vip_integral);
                    contractForm.find('#vip_post_number').val(data.vip_post_number);
                    contractForm.find('#resume_number').val(data.resume_number);
                    contractForm.find('#integral').val(data.integral);
                    contractForm.find('#money').val(data.money);
                    contractForm.find('#vip_days').val(data.vip_days);
                });
            });

            contractForm.find('#responsible_crm_uid').val('{{old('responsible_crm_uid')}}');
            if(contractForm.find('#responsible_crm_uid').val() == '0'){
                addresponsible(contractForm.find('#responsible_crm_uid'));
            }
            //添加销售负责人
            contractForm.find('#responsible_crm_uid').bind("change", function(){
                addresponsible($(this));
            });
        });
        function addresponsible($this){
            if($this.val() == '0'){
                var str = '';
                str += '<span class="addresponsible"><input type="text" style="width:160px;" name="responsible" value="{{old('responsible')}}" id="responsible" placeholder="请填写销售负责人"></span>';
                $this.after(str);
            }else{
                $this.parents('dl').find('.addresponsible').remove();
            }
        }
        //蓝色风格
        $.jeDate('#start_time', {
            format: 'YYYY-MM-DD hh:mm:ss',
            festival: true
        });
        $.jeDate('#end_time', {
            format: 'YYYY-MM-DD hh:mm:ss',
            festival: true
        });
        $.jeDate('#pay_time', {
            format: 'YYYY-MM-DD hh:mm:ss',
            isinitVal:true,                            //是否初始化时间，默认不初始化时间
            festival: true
        });
    </script>
@endsection

